package com.hc.commodity.dao.impl;

import com.hc.commodity.dao.CommodityDao;
import com.hc.commodity.pojo.Commodity;
import com.hc.commodity.utils.JdbcUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * @author hs
 */
public class CommodityDaoImpl implements CommodityDao {
    @Override
    public List<Commodity> findAll() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(JdbcUtils.getDataSource());
        List<Commodity> commodityList = jdbcTemplate.query("select * FROM commodity", new BeanPropertyRowMapper<Commodity>(Commodity.class));
        return commodityList;
    }
}
